package com.nageoffer.shortlink.project.controller;

import com.nageoffer.shortlink.common.convention.result.Result;
import com.nageoffer.shortlink.common.convention.result.Results;
import com.nageoffer.shortlink.common.dto.project.req.ShortLinkMoveToBinReqDTO;
import com.nageoffer.shortlink.common.dto.project.resp.ShortLinkPageBinRespDTO;
import com.nageoffer.shortlink.project.dto.req.ShortLinkPageBinReqDTO;
import com.nageoffer.shortlink.project.service.RecycleBinService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/short-link/recycle-bin")
public class RecycleBinController {
    private final RecycleBinService recycleBinService;
    @PostMapping("/save")
    public Result<Void> moveToRecycleBin(@RequestBody ShortLinkMoveToBinReqDTO reqParam){
        recycleBinService.moveToRecycleBin(reqParam);
        return Results.success();
    }
    @GetMapping("/page")
    public Result<List<ShortLinkPageBinRespDTO>> pageRecycleBin(ShortLinkPageBinReqDTO reqParam){
        List<ShortLinkPageBinRespDTO> pageBean= recycleBinService.pageRecycleBin(reqParam);
        return Results.success(pageBean);
    }

    @PostMapping("/back")
    public Result<Void> backFromRecycleBin(@RequestBody ShortLinkMoveToBinReqDTO reqParam){
        recycleBinService.backFromRecycleBin(reqParam);
        return Results.success();
    }
    @DeleteMapping
    public Result<Void> delFromRecycleBin(@RequestBody ShortLinkMoveToBinReqDTO reqParam){
        recycleBinService.delFromRecycleBin(reqParam);
        return Results.success();
    }
}
